<?php

require_once("model/Database.php");
require_once("model/DBConfig.php");
require_once("controller/Login.php");
require_once("controller/Register.php");
require_once("view/Login.php");
require_once("view/Register.php");
require_once("view/Validator.php");
require_once("model/Login.php");
require_once("model/Register.php");
require_once("view/Page.php");

class MasterController {
	
	public static function do_control() {
		
		// Upprätta databasanslutning
		$db = new \Model\Database();
		$db->connect(new \Model\DBConfig());
		
		// Kolla vilken controller/view som ska köras
		if (isset($_GET['c']) && $_GET['c'] == "register") {
			$controller = new \Controller\Register();
			$view = new \View\Register();
		} else {
			$controller = new \Controller\Login();
			$view = new \View\Login();
		}
		
		$html = $controller->do_control($db, $view);
		
		// Stäng databasanslutning
		$db->close();
		
		// Generera HTML
		$page_view = new \View\Page();
		
		return $page_view->html5("1DV408 - Labb 3", $html);
		
	}
	
}

echo MasterController::do_control();

?>